*********************************************************************************
*** Figure 3
*********************************************************************************

* Project: 	European public opinion twd collective defence
* Authors: 	Matthias Mader
* Date:		July 2023	

* Data: Eurobarometer, YouGov data (third party)

*********************************************************************************

*** Setup

	clear
	set more off            						// Disable partitioned output
	set dp period									// Use comma instead of dot for decimals
	set linesize 80         						// Line size limit to make output more readable
	macro drop _all         						// clear all macros
	set scheme plotplainblind						// set graph scheme, e.g., cleanplots, plottig, plotplainblind, burd3, s1mono
	graph set window fontface "Arial"				// set font in graphs | "Arial" | "Times New Roman"


*********************************************************************************
*** Open Clean EB data
*********************************************************************************


*** Trust in NATO

	use "DATA_clean_EB.dta", clear

	keep if country == 1 | country == 4 |country == 5 |country == 9 |country == 12 |country == 16 |country == 17 |country == 21 |country == 22 |country == 26
	fre country
	label define COUNTRY 1 "France" 4 "Germany" 5 "Italy" 9 "UK" 12 "Spain" 16 "Finland" 17 "Sweden" 21 "Estonia" 22 "Hungary" 26 "Poland", modify
	fre country

* Figure 3, left panel
	graph dot t_nato963 t_nato975, over(country, sort(t_nato975) label(labsize(med)) axis(noline) relabel(`r(relabel)')) ///
		name(F3_1, replace) ///
		marker(1, msize(large) msymbol(circle) 	mcolor(eltblue))   /// 
		marker(2, msize(large) msymbol(circle) 	mcolor(red))   /// 
		title("         Do you tend to trust following institution         " "or tend not to trust it? -- NATO" , size(med) box) ///
		yscale(range(0 1)) ylabel(0 "0" .125 " " .25 "25" .375 " " .5 "50" .625 " " .75 "75" .875 " "1 "100", labsize(med)) ///
		ytitle("Tend to trust (%)", size(med)) ///
		ylab(,grid) ///
		legend(ring(1) position(6) row(1) order(1 "01/2022" 2 "06/2022") size(med)) ///
		yline(.5) ///  
		plotregion(margin(zero) lcolor(black)) ///
		graphregion(margin(0 3 0 0)) ///
		xsize(3) ysize(3.5)

	*** See Excel file
	tab country, sum(t_nato975)
	tab country, sum(t_nato963)


*** Importance of NATO

	use "Data_clean_3rdparty.dta", clear

	*Country variable for ordering
	fre country
	recode country (10 = 1 "Italy") (1 = 2 "France") (9 = 3 "Spain") (2 = 4 "Germany") (6 = 5 "Hungary") (3 = 6 "UK") (11 = 7 "Estonia") (5 = 8 "Sweden") (4 = 9 "Poland") (8 = 10 "Finland"), gen(country2)
	sort country2

* Figure 3, right panel
	graph dot nato21 nato22 ///
		, over(country2, label(labsize(med)) axis(noline)) ///
		name(F3_2, replace) ///
		marker(1, msize(large) msymbol(circle) 	mcolor(eltblue))   /// 
		marker(2, msize(large) msymbol(circle) 	mcolor(red))   /// 
		title("            How important, if at all, do you think            " "NATO is to defence in [COUNTRY]?", size(med) box) ///
		yscale(range(0 1)) ylabel(0 "0" 12.5 " " 25 "25" 37.5 " " 50 "50" 62.5 " " 75 "75" 87.5 " "100 "100", labsize(med)) ///
		ytitle("Very/fairly important (%)", size(med)) ///
		ylab(,grid) ///
		legend(ring(1) position(6) row(1) order(1 "04/2021" 2 "04/2022") size(med)) ///
		yline(50) ///  
		plotregion(margin(zero) lcolor(black)) ///
		graphregion(margin(0 3  0 0)) ///
		xsize(3) ysize(3.5)


